home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / MGRPHTST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  1.7 KB  |  59 lines

  1. // mgrphtst.cpp: Tests the mouse in graphics mode using the 
  2. // cursor shapes defined in mcursor.cpp
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <graphics.h>
  6. #include "msmouse.h"
  7.  
  8. int Err, Mx, My, Gd, Gm, Quad, OldQuad;
  9. unsigned E;       
  10.  
  11. main()
  12. {
  13.   Gd = DETECT;
  14.   initgraph(&Gd, &Gm, "c:\\tcpp\\bgi");  // Initialize graphics mode
  15.   if (graphresult() != grOk) { // Graphics initialization failed
  16.     cprintf("A graphics adapter is required for this program.\r\n");
  17.     exit(1);
  18.   }
  19.   // Draw and label quadrants
  20.   moveto(getmaxx() / 2, 0);
  21.   lineto(getmaxx() / 2, getmaxx());
  22.   moveto(0, getmaxy() / 2);
  23.   lineto(getmaxx(), getmaxy() / 2);
  24.   outtextxy(1, 1, "ArrowCursor");
  25.   outtextxy((getmaxx()/2)+4, 1, "HandCursor");
  26.   outtextxy(1, (getmaxy()/2)+4, "LeftRightCursor");
  27.   outtextxy((getmaxx()/2)+4, (getmaxy()/2) + 4, "UpDownCursor");
  28.   Mouse.Setup(Graphics);    // Initialize the mouse
  29.   if (!Mouse.Operating()) {
  30.     closegraph();
  31.     cprintf("Mouse not detected.\n");
  32.     exit(1);
  33.   }
  34.   Mouse.SetGCursor(ArrowCursor);  // Use this as default cursor
  35.   OldQuad = Quad = 1;
  36.   do {
  37.     E = Mouse.Event(Mx,My);
  38.     if (Mx > getmaxx() / 2) {
  39.        if (My > getmaxy() / 2) Quad = 4; else Quad = 2;
  40.     }
  41.     else {
  42.       if (My > getmaxy() / 2) Quad = 3; else Quad = 1;
  43.     } 
  44.     if (Quad != OldQuad) {
  45.        switch(Quad) {
  46.          case 1: Mouse.SetGCursor(ArrowCursor); break;
  47.          case 2: Mouse.SetGCursor(HandCursor); break;
  48.          case 3: Mouse.SetGCursor(LeftRightCursor); break;
  49.          case 4: Mouse.SetGCursor(UpDownCursor); break;
  50.        };
  51.     }
  52.     OldQuad = Quad;
  53.   } while (E != MouseDown);
  54.   Mouse.TurnOff();
  55.   closegraph();
  56.   return 0;
  57. }
  58.  
  59.